<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>GCC4.4.0源码剖析 | whoway</title>
    <meta name="description" content="Personal Blog Website">
    <link rel="icon" href="/images/photo.jpg">
  <link rel="manifest" href="/images/photo.jpg">
  <link rel="apple-touch-icon" href="/images/photo.jpg">
  <meta http-quiv="pragma" cotent="no-cache">
  <meta http-quiv="pragma" cotent="no-cache,must-revalidate">
  <meta http-quiv="expires" cotent="0">
    
    <link rel="preload" href="/assets/css/0.styles.0dbae9ec.css" as="style"><link rel="preload" href="/assets/js/app.c70e21ad.js" as="script"><link rel="preload" href="/assets/js/115.e51d3c2f.js" as="script"><link rel="prefetch" href="/assets/js/10.15222a53.js"><link rel="prefetch" href="/assets/js/100.7e0e5a86.js"><link rel="prefetch" href="/assets/js/101.efd59f25.js"><link rel="prefetch" href="/assets/js/102.dfbdc06c.js"><link rel="prefetch" href="/assets/js/103.d3ab2109.js"><link rel="prefetch" href="/assets/js/104.117957ef.js"><link rel="prefetch" href="/assets/js/105.046e8ff3.js"><link rel="prefetch" href="/assets/js/106.aebdc17d.js"><link rel="prefetch" href="/assets/js/107.248733c2.js"><link rel="prefetch" href="/assets/js/108.a2fecadc.js"><link rel="prefetch" href="/assets/js/109.35196857.js"><link rel="prefetch" href="/assets/js/11.770642f2.js"><link rel="prefetch" href="/assets/js/110.cf3d973c.js"><link rel="prefetch" href="/assets/js/111.f985889a.js"><link rel="prefetch" href="/assets/js/112.ad614f41.js"><link rel="prefetch" href="/assets/js/113.f666653c.js"><link rel="prefetch" href="/assets/js/114.c6c3f384.js"><link rel="prefetch" href="/assets/js/116.4f4b39f5.js"><link rel="prefetch" href="/assets/js/117.99352e11.js"><link rel="prefetch" href="/assets/js/118.c6ae6572.js"><link rel="prefetch" href="/assets/js/119.4ccbe778.js"><link rel="prefetch" href="/assets/js/12.042a92ff.js"><link rel="prefetch" href="/assets/js/120.edda1c4f.js"><link rel="prefetch" href="/assets/js/121.30a638ed.js"><link rel="prefetch" href="/assets/js/122.6efcefb1.js"><link rel="prefetch" href="/assets/js/123.91e6665b.js"><link rel="prefetch" href="/assets/js/124.f27e3d7e.js"><link rel="prefetch" href="/assets/js/125.c75712d5.js"><link rel="prefetch" href="/assets/js/126.ed756cce.js"><link rel="prefetch" href="/assets/js/127.2f06c74c.js"><link rel="prefetch" href="/assets/js/128.d5f6f30e.js"><link rel="prefetch" href="/assets/js/129.508b7eed.js"><link rel="prefetch" href="/assets/js/13.b5280c37.js"><link rel="prefetch" href="/assets/js/130.dc05f9aa.js"><link rel="prefetch" href="/assets/js/131.e0ba69b1.js"><link rel="prefetch" href="/assets/js/132.d79bcaa4.js"><link rel="prefetch" href="/assets/js/133.34acc01a.js"><link rel="prefetch" href="/assets/js/134.dabf64d5.js"><link rel="prefetch" href="/assets/js/135.ad90c915.js"><link rel="prefetch" href="/assets/js/136.dbb0074f.js"><link rel="prefetch" href="/assets/js/137.284ad365.js"><link rel="prefetch" href="/assets/js/138.a4b6856f.js"><link rel="prefetch" href="/assets/js/139.c9c1e20f.js"><link rel="prefetch" href="/assets/js/14.df02ba38.js"><link rel="prefetch" href="/assets/js/140.8b0a9269.js"><link rel="prefetch" href="/assets/js/141.9c7759c5.js"><link rel="prefetch" href="/assets/js/142.a4201a82.js"><link rel="prefetch" href="/assets/js/143.d7da6e8c.js"><link rel="prefetch" href="/assets/js/144.5e48e65d.js"><link rel="prefetch" href="/assets/js/145.a0e2633c.js"><link rel="prefetch" href="/assets/js/146.3c775f9b.js"><link rel="prefetch" href="/assets/js/147.22add89a.js"><link rel="prefetch" href="/assets/js/148.cfde1009.js"><link rel="prefetch" href="/assets/js/149.ffc835b5.js"><link rel="prefetch" href="/assets/js/15.fbdfc4ee.js"><link rel="prefetch" href="/assets/js/150.406c4b20.js"><link rel="prefetch" href="/assets/js/151.b2040eea.js"><link rel="prefetch" href="/assets/js/152.7bc65661.js"><link rel="prefetch" href="/assets/js/153.1d7c65e3.js"><link rel="prefetch" href="/assets/js/154.1309de49.js"><link rel="prefetch" href="/assets/js/155.81d3ee1f.js"><link rel="prefetch" href="/assets/js/156.154a4ef2.js"><link rel="prefetch" href="/assets/js/16.e5eb6147.js"><link rel="prefetch" href="/assets/js/17.57853c4a.js"><link rel="prefetch" href="/assets/js/18.cb9d7518.js"><link rel="prefetch" href="/assets/js/19.f354dc47.js"><link rel="prefetch" href="/assets/js/2.570d8a23.js"><link rel="prefetch" href="/assets/js/20.b5af7fad.js"><link rel="prefetch" href="/assets/js/21.0b1928fe.js"><link rel="prefetch" href="/assets/js/22.f78666de.js"><link rel="prefetch" href="/assets/js/23.29c3f366.js"><link rel="prefetch" href="/assets/js/24.6f596516.js"><link rel="prefetch" href="/assets/js/25.14067b60.js"><link rel="prefetch" href="/assets/js/26.74ba4989.js"><link rel="prefetch" href="/assets/js/27.13d60edd.js"><link rel="prefetch" href="/assets/js/28.9523cb32.js"><link rel="prefetch" href="/assets/js/29.8ec842e9.js"><link rel="prefetch" href="/assets/js/3.3fb3d2e0.js"><link rel="prefetch" href="/assets/js/30.805597a8.js"><link rel="prefetch" href="/assets/js/31.831b195d.js"><link rel="prefetch" href="/assets/js/32.063c672d.js"><link rel="prefetch" href="/assets/js/33.6d93fac3.js"><link rel="prefetch" href="/assets/js/34.56e8263c.js"><link rel="prefetch" href="/assets/js/35.dbe688bb.js"><link rel="prefetch" href="/assets/js/36.dc5af2c1.js"><link rel="prefetch" href="/assets/js/37.0a7494f6.js"><link rel="prefetch" href="/assets/js/38.fe4fc171.js"><link rel="prefetch" href="/assets/js/39.f5ed5e92.js"><link rel="prefetch" href="/assets/js/4.2c405ec8.js"><link rel="prefetch" href="/assets/js/40.fe7e2714.js"><link rel="prefetch" href="/assets/js/41.30b0811d.js"><link rel="prefetch" href="/assets/js/42.76f52d62.js"><link rel="prefetch" href="/assets/js/43.e7bb0817.js"><link rel="prefetch" href="/assets/js/44.ead0e883.js"><link rel="prefetch" href="/assets/js/45.235df046.js"><link rel="prefetch" href="/assets/js/46.5f09e829.js"><link rel="prefetch" href="/assets/js/47.67116354.js"><link rel="prefetch" href="/assets/js/48.31f34543.js"><link rel="prefetch" href="/assets/js/49.10b5ebba.js"><link rel="prefetch" href="/assets/js/5.6f47322c.js"><link rel="prefetch" href="/assets/js/50.c0f0b7f1.js"><link rel="prefetch" href="/assets/js/51.5143f3bf.js"><link rel="prefetch" href="/assets/js/52.eeddfd48.js"><link rel="prefetch" href="/assets/js/53.eb790db5.js"><link rel="prefetch" href="/assets/js/54.8fe5421c.js"><link rel="prefetch" href="/assets/js/55.d8f9004b.js"><link rel="prefetch" href="/assets/js/56.62ac9b92.js"><link rel="prefetch" href="/assets/js/57.a9caec0d.js"><link rel="prefetch" href="/assets/js/58.f93fc522.js"><link rel="prefetch" href="/assets/js/59.a81a03aa.js"><link rel="prefetch" href="/assets/js/6.8c2ea393.js"><link rel="prefetch" href="/assets/js/60.ab782775.js"><link rel="prefetch" href="/assets/js/61.6dd12daf.js"><link rel="prefetch" href="/assets/js/62.76f4b01f.js"><link rel="prefetch" href="/assets/js/63.6f8a4742.js"><link rel="prefetch" href="/assets/js/64.6f8bb1fa.js"><link rel="prefetch" href="/assets/js/65.4120a44b.js"><link rel="prefetch" href="/assets/js/66.360c2d2b.js"><link rel="prefetch" href="/assets/js/67.26f84d32.js"><link rel="prefetch" href="/assets/js/68.68f45e5e.js"><link rel="prefetch" href="/assets/js/69.e311eb56.js"><link rel="prefetch" href="/assets/js/7.6762b2d7.js"><link rel="prefetch" href="/assets/js/70.cea82674.js"><link rel="prefetch" href="/assets/js/71.783ddcf7.js"><link rel="prefetch" href="/assets/js/72.e5467385.js"><link rel="prefetch" href="/assets/js/73.b8fb681b.js"><link rel="prefetch" href="/assets/js/74.1bae37db.js"><link rel="prefetch" href="/assets/js/75.024387e5.js"><link rel="prefetch" href="/assets/js/76.a8e53010.js"><link rel="prefetch" href="/assets/js/77.8c55500a.js"><link rel="prefetch" href="/assets/js/78.7ce90bf5.js"><link rel="prefetch" href="/assets/js/79.ef71713f.js"><link rel="prefetch" href="/assets/js/8.788a6364.js"><link rel="prefetch" href="/assets/js/80.acad589d.js"><link rel="prefetch" href="/assets/js/81.02670d10.js"><link rel="prefetch" href="/assets/js/82.53b7b1ac.js"><link rel="prefetch" href="/assets/js/83.99eb8581.js"><link rel="prefetch" href="/assets/js/84.d1535ce3.js"><link rel="prefetch" href="/assets/js/85.fe2b7de9.js"><link rel="prefetch" href="/assets/js/86.41850272.js"><link rel="prefetch" href="/assets/js/87.1cdc6df9.js"><link rel="prefetch" href="/assets/js/88.01bf3461.js"><link rel="prefetch" href="/assets/js/89.17c69819.js"><link rel="prefetch" href="/assets/js/9.3813842d.js"><link rel="prefetch" href="/assets/js/90.f6ae7e35.js"><link rel="prefetch" href="/assets/js/91.507bc284.js"><link rel="prefetch" href="/assets/js/92.90551782.js"><link rel="prefetch" href="/assets/js/93.dc442d78.js"><link rel="prefetch" href="/assets/js/94.315f4e94.js"><link rel="prefetch" href="/assets/js/95.ccd6c6bf.js"><link rel="prefetch" href="/assets/js/96.0c6d89d0.js"><link rel="prefetch" href="/assets/js/97.1a9f10a9.js"><link rel="prefetch" href="/assets/js/98.43be3caa.js"><link rel="prefetch" href="/assets/js/99.54c8207b.js">
    <link rel="stylesheet" href="/assets/css/0.styles.0dbae9ec.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">whoway</span></a> <div class="links" style="max-width:nullpx;"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🎓Coding</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/00.Coding/TheBeautyOfProgramming/" class="nav-link">🔖编程之美题解</a></li><li class="dropdown-item"><!----> <a href="/00.Coding/CodeWarehouse/" class="nav-link">🔖代码意识流</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🚀语言</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/01.Language/Overview/" class="nav-link">🔖概述</a></li><li class="dropdown-item"><!----> <a href="/01.Language/C/" class="nav-link">⭐️C</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Cpp/" class="nav-link">🚀C++</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Java/" class="nav-link">☕️Java</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Python/" class="nav-link">🧩Python3</a></li></ul></div></div><div class="nav-item"><a href="/02.Hardware/" class="nav-link">✔️硬件基础</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⭐️软件基础</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/03.Software/01.DataStructureAndAlgorithm/" class="nav-link">🐾数据结构和算法</a></li><li class="dropdown-item"><!----> <a href="/03.Software/02.OS/" class="nav-link">💻操作系统</a></li><li class="dropdown-item"><!----> <a href="/03.Software/03.Net/" class="nav-link">☁️计算机网络</a></li><li class="dropdown-item"><!----> <a href="/03.Software/04.SE/" class="nav-link">✅软件工程</a></li></ul></div></div><div class="nav-item"><a href="/04.Database/" class="nav-link">🎨数据库</a></div><div class="nav-item"><a href="/05.Engineer/" class="nav-link router-link-active">🔖学术/工程</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⚙️工具</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/06.Tools/01.employment/" class="nav-link">🔖求职</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/02.efficiency/" class="nav-link">🚀效能</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/03.windows/" class="nav-link">⚙️Windows</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/04.design/" class="nav-link">🧩设计</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/05.linux/" class="nav-link">🐉Linux</a></li></ul></div></div><div class="nav-item"><a href="https://github.com/whoway" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar"><nav class="nav-links"><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🎓Coding</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/00.Coding/TheBeautyOfProgramming/" class="nav-link">🔖编程之美题解</a></li><li class="dropdown-item"><!----> <a href="/00.Coding/CodeWarehouse/" class="nav-link">🔖代码意识流</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🚀语言</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/01.Language/Overview/" class="nav-link">🔖概述</a></li><li class="dropdown-item"><!----> <a href="/01.Language/C/" class="nav-link">⭐️C</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Cpp/" class="nav-link">🚀C++</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Java/" class="nav-link">☕️Java</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Python/" class="nav-link">🧩Python3</a></li></ul></div></div><div class="nav-item"><a href="/02.Hardware/" class="nav-link">✔️硬件基础</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⭐️软件基础</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/03.Software/01.DataStructureAndAlgorithm/" class="nav-link">🐾数据结构和算法</a></li><li class="dropdown-item"><!----> <a href="/03.Software/02.OS/" class="nav-link">💻操作系统</a></li><li class="dropdown-item"><!----> <a href="/03.Software/03.Net/" class="nav-link">☁️计算机网络</a></li><li class="dropdown-item"><!----> <a href="/03.Software/04.SE/" class="nav-link">✅软件工程</a></li></ul></div></div><div class="nav-item"><a href="/04.Database/" class="nav-link">🎨数据库</a></div><div class="nav-item"><a href="/05.Engineer/" class="nav-link router-link-active">🔖学术/工程</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⚙️工具</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/06.Tools/01.employment/" class="nav-link">🔖求职</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/02.efficiency/" class="nav-link">🚀效能</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/03.windows/" class="nav-link">⚙️Windows</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/04.design/" class="nav-link">🧩设计</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/05.linux/" class="nav-link">🐉Linux</a></li></ul></div></div><div class="nav-item"><a href="https://github.com/whoway" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav>  <ul class="sidebar-links"><li><div class="sidebar-group first"><p class="sidebar-heading open"><span>GCC4.4.0源码剖析</span> <!----></p> <ul class="sidebar-group-items"><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#目录" class="sidebar-link">目录</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#a1-gcc相关资料⭐️" class="sidebar-link">A1.GCC相关资料⭐️</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#a1-环境配置⭐️✔️" class="sidebar-link">A1.环境配置⭐️✔️</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_1-1-源代码下载" class="sidebar-link">1.1.源代码下载</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_1-2-gcc源码编译⭐️" class="sidebar-link">1.2.GCC源码编译⭐️</a></li></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#a3-工具准备✔️" class="sidebar-link">A3.工具准备✔️</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_3-1-配置vim-ctags代码阅读" class="sidebar-link">3.1.配置vim+ctags代码阅读</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_3-2-调试工具gdb⭐️" class="sidebar-link">3.2.调试工具gdb⭐️</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_3-3-gnu-binutils工具集" class="sidebar-link">3.3.GNU binutils工具集</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_3-4-shell的3个工具-grep、sed、awk" class="sidebar-link">3.4.Shell的3个工具-grep、sed、awk</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_3-5-图形化的linux的graphviz工具" class="sidebar-link">3.5.图形化的Linux的graphviz工具</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_3-6-⭐️gcc调试选项「核心」⭐️" class="sidebar-link">3.6.⭐️GCC调试选项「核心」⭐️</a></li></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#a4-工程技巧" class="sidebar-link">A4.工程技巧</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_4-1-增量编译" class="sidebar-link">4.1.增量编译</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_4-2-辅助看gcc源码的网站" class="sidebar-link">4.2.辅助看gcc源码的网站</a></li></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_2-gcc的逻辑结构" class="sidebar-link">2.GCC的逻辑结构</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_10-从gimple到rtl" class="sidebar-link">10.从Gimple到RTL</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_10-1-gimple序列" class="sidebar-link">10.1.Gimple序列</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_10-2-典型数据结构" class="sidebar-link">10.2.典型数据结构</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_10-3-rtl生成的基本过程" class="sidebar-link">10.3.RTL生成的基本过程</a></li></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#工程经验" class="sidebar-link">工程经验</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#_1-给你的peephol2优化添加控制选项" class="sidebar-link">1.给你的peephol2优化添加控制选项</a></li></ul></li><li><a href="/05.Engineer/tool/Base.GCC4.4.0%E6%BA%90%E7%A0%81%E5%89%96%E6%9E%90.html#参考资料" class="sidebar-link">参考资料</a><ul class="sidebar-sub-headers"></ul></li></ul></div></li></ul> </div> <div class="page"> <div class="content"><h1 id="gcc4-4-0源码剖析"><a href="#gcc4-4-0源码剖析" class="header-anchor">#</a> <code>GCC4.4.0</code>源码剖析</h1> <ul><li>⭐️：工程实践经验</li> <li>✔️：已完成</li> <li>配合教材：《深入分析GCC》</li></ul> <h2 id="目录"><a href="#目录" class="header-anchor">#</a> 目录</h2> <p>[TOC]</p> <h2 id="a1-gcc相关资料⭐️"><a href="#a1-gcc相关资料⭐️" class="header-anchor">#</a> A1.GCC相关资料⭐️</h2> <blockquote><p>gcc相关文档</p></blockquote> <ul><li><p>gcc的官方Wiki：<a href="https://gcc.gnu.org/wiki/" target="_blank" rel="noopener noreferrer">https://gcc.gnu.org/wiki/<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p></li> <li><p>GCC online documentation（实现）：<a href="https://gcc.gnu.org/onlinedocs/" target="_blank" rel="noopener noreferrer">https://gcc.gnu.org/onlinedocs/<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <ul><li>但是没有各个版本的inter</li></ul></li> <li><p>源码下载ftp：<a href="https://ftp.gnu.org/gnu/gcc/gcc-4.1.0/" target="_blank" rel="noopener noreferrer">https://ftp.gnu.org/gnu/gcc/gcc-4.1.0/<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p></li> <li><p>release：<a href="https://gcc.gnu.org/releases.html" target="_blank" rel="noopener noreferrer">https://gcc.gnu.org/releases.html<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <ul><li><p>0.5.<code>GCC 4.1</code> Release Series『发布系列』</p></li> <li><p>Release History</p> <ul><li><p>GCC 4.1.2</p> <p>February 13, 2007 (<a href="https://gcc.gnu.org/gcc-4.1/changes.html#4.1.2" target="_blank" rel="noopener noreferrer">changes<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>)</p></li> <li><p>GCC 4.1.1</p> <p>May 24, 2006 (<a href="https://gcc.gnu.org/gcc-4.1/changes.html" target="_blank" rel="noopener noreferrer">changes<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>)</p></li> <li><p>GCC 4.1.0</p> <p>February 28, 2006 (<a href="https://gcc.gnu.org/gcc-4.1/changes.html" target="_blank" rel="noopener noreferrer">changes<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>)</p></li></ul></li></ul></li></ul> <blockquote><p>某次优化点</p></blockquote> <p>1.论文实现的网站</p> <ul><li><a href="https://gcc.gnu.org/projects/cfo.html" target="_blank" rel="noopener noreferrer">https://gcc.gnu.org/projects/cfo.html<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul> <p>2.GCC: Anonymous read-only Git access</p> <ul><li>提到了cfo-branch</li> <li><a href="https://gcc.gnu.org/git.html" target="_blank" rel="noopener noreferrer">https://gcc.gnu.org/git.html<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul> <h2 id="a1-环境配置⭐️✔️"><a href="#a1-环境配置⭐️✔️" class="header-anchor">#</a> A1.环境配置⭐️✔️</h2> <h3 id="_1-1-源代码下载"><a href="#_1-1-源代码下载" class="header-anchor">#</a> 1.1.源代码下载</h3> <ul><li>下载源代码</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token punctuation">[</span>root@CentosLinux ~<span class="token punctuation">]</span><span class="token comment"># wget -c http://mirror1.babylon.network/gcc/releases/gcc-4.4.0/gcc-4.4.0.tar.bz2</span>
--2021-11-26 <span class="token number">10</span>:56:01--  http://mirror1.babylon.network/gcc/releases/gcc-4.4.0/gcc-4.4.0.tar.bz2
Resolving mirror1.babylon.network <span class="token punctuation">(</span>mirror1.babylon.network<span class="token punctuation">)</span><span class="token punctuation">..</span>. failed: Name or <span class="token function">service</span> not known.
wget: unable to resolve <span class="token function">host</span> address ‘mirror1.babylon.network’
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><ul><li>发现不行，用下面</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">wget</span> -c https://ftp.gnu.org/gnu/gcc/gcc-4.4.0/gcc-4.4.0.tar.bz2
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>解压缩</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">tar</span> xjvf gcc-4.4.0.tar.bz2
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_1-2-gcc源码编译⭐️"><a href="#_1-2-gcc源码编译⭐️" class="header-anchor">#</a> 1.2.GCC源码编译⭐️</h3> <ul><li>Linux From Scratch：http://www.jinbuguo.com/lfs/lfs62/index.html</li> <li><a href="https://www.cnblogs.com/alianbog/p/12498915.html" target="_blank" rel="noopener noreferrer">GCC源码编译<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul> <h4 id="_1-2-1-下载依赖"><a href="#_1-2-1-下载依赖" class="header-anchor">#</a> 1.2.1.下载依赖</h4> <p>Gcc 的三大件前面已经提到过了，而它们在安装时也存在依赖关系</p> <ul><li>mpfr 需要依赖 gmp，mpc 则是依赖 gmp 和 mpfr，因此安装的顺序是 gmp，mpfr，最后才是 mpc。</li> <li>依赖关系参考教程：https://jcf94.com/2016/04/15/2016-04-15-gcc/</li></ul> <div class="language-mermaid line-numbers-mode"><pre class="language-text"><code>graph LR
gmp--&gt;mpfr--&gt;mpc
gmp--&gt;mpc
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>gmp（公司有类似的）</p> <ul><li>GMP(The GNU Multiple Precision Arithmetic Library)又叫<strong>GNU多精度算术库</strong>，是一个提供了很多操作高精度的大整数，浮点数的运算的算术库，几乎没有什么精度方面的限制，功能丰富。我刚接触到这个东西的时候是在学习PHP的过程中。GMP的主要目标应用领域是密码学的应用和研究、 互联网安全应用、 代数系统、 计算代数研究等。</li> <li>参考资料：https://www.cnblogs.com/ECJTUACM-873284962/p/8350320.html</li></ul> <p>mpfr</p> <ul><li>MPFR：GNU多精度浮点舍入库</li> <li>官网：https://www.mpfr.org/</li></ul> <p>mpc</p> <ul><li>MPC：GNU多精度C库</li> <li>https://ftp.gnu.org/gnu/mpc/</li></ul> <h4 id="_1-2-2-扩展的"><a href="#_1-2-2-扩展的" class="header-anchor">#</a> 1.2.2.扩展的</h4> <ul><li>ELF：可执行和可链接格式库</li> <li>PPL：Parma Polyhedra库（PPL非必需）（可选，用于内存优化）</li> <li>isl库：（ISL非必需）：isl是一个用于多面体模型调度实现的c/c++库。通过isl，我们可以对模型进行自动的调度，循环优化等。</li> <li>expat：Expat是一个用C语言开发的、用来解析XML文档的开发库，它最初是开源的、Mozilla 项目下的一个<a href="https://baike.baidu.com/item/XML%E8%A7%A3%E6%9E%90%E5%99%A8/2673664" target="_blank" rel="noopener noreferrer">XML解析器<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>。</li> <li>libiconv库：libiconv库是一个基于GNU协议的开源库，主要是解决多语言编码处理转换等应用问题由于历史原因，国际化的文字常常由于语言或者国家的原因使用不同的编码。Libiconv是一个常用的编码转换库，支持常用的多种编码之间的转换，主要函数有：</li> <li>dejagnu库：DejaGnu 是一个非常好的开源的测试工具，尤其是做 GNU 开源工具链的软件开发，更离不开 DejaGnu 的支持，因为 binutils, gcc, gdb 自带的[<strong>测试用例</strong>](javascript:;)都是使用 DejaGnu 进行测试的。但是，DejaGnu 也有一些不足之处。因为它是开源的，我们可以修改它来满足我们的需求。</li> <li>riscv-isa-sim：riscv-isa-sim是一个RISC-V指令的仿真器，riscv-isa-sim的正常运行需要依赖<strong>riscv-pk</strong>和riscv-fesvr工具。前面有对这些工具的说明。riscv-isa-sim编译后主要用到的工具是spike。其实spike不单单可以仿真RISC-V指令的，还能仿真Linux系统。</li></ul> <h2 id="a3-工具准备✔️"><a href="#a3-工具准备✔️" class="header-anchor">#</a> A3.工具准备✔️</h2> <h3 id="_3-1-配置vim-ctags代码阅读"><a href="#_3-1-配置vim-ctags代码阅读" class="header-anchor">#</a> 3.1.配置vim+ctags代码阅读</h3> <ul><li>安装ctags</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">sudo</span> yum <span class="token function">install</span> ctags

ctags --version
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><ul><li>运行</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token builtin class-name">cd</span> gcc-4.4.0/
ctags -R
ll -rt
-rw-r--r--  <span class="token number">1</span> root root <span class="token number">52363468</span> Nov <span class="token number">26</span> <span class="token number">11</span>:10 tags
<span class="token function">ls</span> -l tags
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li>还可以尝试SourceInsight和VScode</li></ul> <h3 id="_3-2-调试工具gdb⭐️"><a href="#_3-2-调试工具gdb⭐️" class="header-anchor">#</a> 3.2.调试工具<code>gdb</code>⭐️</h3> <ul><li>内部命令使用「组会中学到的」</li> <li>gdb命令工具网站：<a href="https://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/gdb.html" target="_blank" rel="noopener noreferrer">https://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/gdb.html<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>si	<span class="token comment">#单条指令执行</span>
layout prev
layout asm	<span class="token comment">#显示反汇编窗口</span>
layout regs	<span class="token comment">#显示源代码/反汇编和CPU寄存器窗口</span>
layout previous
disable
remote tagert:端口号	<span class="token comment">#第1次看到，这样和qemu联合调试</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="_3-3-gnu-binutils工具集"><a href="#_3-3-gnu-binutils工具集" class="header-anchor">#</a> 3.3.GNU binutils工具集</h3> <ul><li>objdump</li> <li>ld</li> <li>nm</li></ul> <h3 id="_3-4-shell的3个工具-grep、sed、awk"><a href="#_3-4-shell的3个工具-grep、sed、awk" class="header-anchor">#</a> 3.4.Shell的3个工具-grep、sed、awk</h3> <h3 id="_3-5-图形化的linux的graphviz工具"><a href="#_3-5-图形化的linux的graphviz工具" class="header-anchor">#</a> 3.5.图形化的Linux的graphviz工具</h3> <h3 id="_3-6-⭐️gcc调试选项「核心」⭐️"><a href="#_3-6-⭐️gcc调试选项「核心」⭐️" class="header-anchor">#</a> 3.6.⭐️GCC调试选项「核心」⭐️</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>gcc -fdump-tree-all test.c
gcc -fdump-rtl-all test.c	<span class="token comment">#生成rtl</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="a4-工程技巧"><a href="#a4-工程技巧" class="header-anchor">#</a> A4.工程技巧</h2> <h3 id="_4-1-增量编译"><a href="#_4-1-增量编译" class="header-anchor">#</a> 4.1.增量编译</h3> <ul><li>在libgcc库里面，所以在编gcc的时候要<strong>加上选项</strong>（宏控制的编译）</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>./build_toolchain.sh update <span class="token string">&quot;-femit-clz -DENABLE_CTZ&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>或许，也可以进行<code>-g</code>的增量编译？</li></ul> <h3 id="_4-2-辅助看gcc源码的网站"><a href="#_4-2-辅助看gcc源码的网站" class="header-anchor">#</a> 4.2.辅助看gcc源码的网站</h3> <ul><li><a href="https://code.woboq.org/" target="_blank" rel="noopener noreferrer">https://code.woboq.org/<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul> <h2 id="_2-gcc的逻辑结构"><a href="#_2-gcc的逻辑结构" class="header-anchor">#</a> 2.GCC的逻辑结构</h2> <p><img src="https://cdn.jsdelivr.net/gh/HACV/picture/img/20211005171001.png" alt="20211005170914"></p> <h2 id="_10-从gimple到rtl"><a href="#_10-从gimple到rtl" class="header-anchor">#</a> 10.从Gimple到RTL</h2> <h3 id="_10-1-gimple序列"><a href="#_10-1-gimple序列" class="header-anchor">#</a> 10.1.Gimple序列</h3> <ul><li>针对Gimple的最后1个关键的“处理过程”为<code>pass_expand</code>，该Pass就完成了Gimple向RTL的转换。
<ul><li>即由Gimple中间结果生成RTL形式的insn</li></ul></li></ul> <h3 id="_10-2-典型数据结构"><a href="#_10-2-典型数据结构" class="header-anchor">#</a> 10.2.典型数据结构</h3> <ul><li>以“<strong>函数</strong>”为<strong>单位</strong>进行RTL生成时，需要对<strong>当前函数</strong>的<strong>RTL信息</strong>进行维护
<ul><li>这个主要由结构体<code>struct rtl_data</code>来描述</li> <li>在<code>gcc/function.h</code>中定义</li></ul></li> <li>在<code>gcc/emit-rtl.c</code>中定义了如下的宏，用来访问<strong>当前函数</strong>正在处理的insn序列</li></ul> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">first_insn</span> <span class="token expression"><span class="token punctuation">(</span>crtl<span class="token operator">-&gt;</span>emit<span class="token punctuation">.</span>x_first_insn<span class="token punctuation">)</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">last_insn</span> <span class="token expression"><span class="token punctuation">(</span>crtl<span class="token operator">-&gt;</span>emit<span class="token punctuation">.</span>x_last_insn<span class="token punctuation">)</span></span></span>
<span class="token macro property"><span class="token directive-hash">#</span><span class="token directive keyword">define</span> <span class="token macro-name">cur_insn_uid</span> <span class="token expression"><span class="token punctuation">(</span>crtl<span class="token operator">-&gt;</span>emit<span class="token punctuation">.</span>x_cur_insn_uid<span class="token punctuation">)</span></span></span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h3 id="_10-3-rtl生成的基本过程"><a href="#_10-3-rtl生成的基本过程" class="header-anchor">#</a> 10.3.RTL生成的基本过程</h3> <ul><li><p>1.变量展开：</p> <ul><li>调用<code>expand_used_vars(void)</code>函数，对当前函数中所有的变量进行分析</li> <li>在虚拟寄存器或者堆栈中为其分配空间，并生成对应的RTX</li></ul></li> <li><p>2.参数和返回值的处理：</p> <ul><li>调用<code>expand_function_start( current_function_decl )</code>函数</li> <li>对函数的参数和返回值进行处理，生成其对应的RTX</li></ul></li> <li><p>3.<strong>初始化块</strong>的处理：</p> <ul><li>调用<code>construt_init_block(void)</code>函数，创建初始化块</li> <li>并修正函数的控制流图CFG</li></ul></li> <li><p>4.基本块的展开：</p> <ul><li>对函数体中的每个基本块所包含的Gimple语句序列逐个进行展开，这是RTL生成的主要部分，采用的形式为：</li></ul> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token function">FOR_BB_BETWEEN</span> <span class="token punctuation">(</span>bb<span class="token punctuation">,</span> init_block<span class="token operator">-&gt;</span>next_bb<span class="token punctuation">,</span> EXIT_BLOCK_PTR<span class="token punctuation">,</span> next_bb <span class="token punctuation">)</span>
    bb <span class="token operator">=</span> <span class="token function">expand_gimple_basic_block</span> <span class="token punctuation">(</span>bb<span class="token punctuation">)</span><span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li>即对函数初始块之后的每个基本块逐一进行展开</li></ul></li> <li><p>5.退出块的处理：</p> <ul><li>调用<code>construct_exit_block(void)</code>函数，<strong>创建退出块</strong></li> <li>生成函数退出时的RTL，并修正函数的控制流图CFG</li></ul></li> <li><p>6.其他处理</p></li></ul> <h4 id="_10-3-1-变量展开"><a href="#_10-3-1-变量展开" class="header-anchor">#</a> 10.3.1.变量展开</h4> <div class="language-c line-numbers-mode"><pre class="language-c"><code><span class="token keyword">int</span> global_int <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
<span class="token keyword">int</span> <span class="token function">gimple2rtl</span><span class="token punctuation">(</span><span class="token keyword">int</span> a<span class="token punctuation">,</span> <span class="token keyword">short</span> b<span class="token punctuation">,</span> <span class="token keyword">char</span> <span class="token operator">*</span> p<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
        <span class="token keyword">int</span> i<span class="token punctuation">;</span>
        <span class="token keyword">static</span> <span class="token keyword">int</span> static_sum<span class="token punctuation">;</span>
        <span class="token keyword">int</span> array<span class="token punctuation">[</span><span class="token number">2</span><span class="token punctuation">]</span><span class="token operator">=</span><span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
        static_sum<span class="token operator">=</span>a<span class="token punctuation">;</span>
        <span class="token keyword">for</span><span class="token punctuation">(</span>i<span class="token operator">=</span>global_int<span class="token punctuation">;</span> i<span class="token operator">&lt;</span>b<span class="token punctuation">;</span> i<span class="token operator">++</span><span class="token punctuation">)</span>
        <span class="token punctuation">{</span>
                <span class="token keyword">int</span> j<span class="token operator">=</span><span class="token operator">*</span>p<span class="token punctuation">;</span>
                static_sum<span class="token operator">=</span>static_sum<span class="token operator">+</span>j<span class="token operator">+</span>array<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span>
                <span class="token keyword">if</span><span class="token punctuation">(</span>static_sum<span class="token operator">&gt;</span><span class="token number">1000</span><span class="token punctuation">)</span> <span class="token keyword">goto</span> Label_RET<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        Label_RET<span class="token operator">:</span>
                <span class="token keyword">return</span> static_sum<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><ul><li>我的测试</li> <li>选项是<code>-fdump-tree-all</code></li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>gcc -c gimple2rtl.c -fdump-tree-all
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>生成了下面的</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">292</span> Nov  <span class="token number">2</span> 07:43 gimple2rtl.c
-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">635</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.004t.original
-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">947</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.005t.gimple
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1044</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.007t.omplower
-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">990</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.008t.lower
-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">867</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.011t.eh
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1202</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.012t.cfg
-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">880</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.013t.ompexp
-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">880</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.014t.printf-return-value1
-rw-rw-r--  <span class="token number">1</span> huwei huwei  <span class="token number">880</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.018t.fixup_cfg1
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.019t.ssa
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.023t.fixup_cfg2
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1373</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.024t.local-fnsummary1
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.025t.einline
-rw-rw-r--  <span class="token number">1</span> huwei huwei    <span class="token number">0</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.043t.profile_estimate
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1093</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.046t.release_ssa
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1373</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.047t.local-fnsummary2
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.085t.fixup_cfg3
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.221t.veclower
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.222t.cplxlower0
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.224t.switchlower_O0
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1052</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.231t.optimized
-rw-rw-r--  <span class="token number">1</span> huwei huwei    <span class="token number">0</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.319t.statistics
-rw-rw-r--  <span class="token number">1</span> huwei huwei    <span class="token number">0</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.320t.earlydebug
-rw-rw-r--  <span class="token number">1</span> huwei huwei    <span class="token number">0</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.c.321t.debug
-rw-rw-r--  <span class="token number">1</span> huwei huwei <span class="token number">1936</span> Nov  <span class="token number">2</span> 07:44 gimple2rtl.o
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br></div></div><h2 id="工程经验"><a href="#工程经验" class="header-anchor">#</a> 工程经验</h2> <h3 id="_1-给你的peephol2优化添加控制选项"><a href="#_1-给你的peephol2优化添加控制选项" class="header-anchor">#</a> 1.给你的<code>peephol2</code>优化添加控制选项</h3> <ul><li>其实添加选项就2个部分，一个在<code>common.opt</code>，一个在后端<code>[xxx].opt</code> <ul><li>比如<code>gcc/config/riscv/riscv.opt</code></li></ul></li></ul> <h2 id="参考资料"><a href="#参考资料" class="header-anchor">#</a> 参考资料</h2> <ul><li>gcc源代码下载：<a href="http://mirror1.babylon.network/gcc/releases/gcc-4.4.0/gcc-4.4.0.tar.bz2" target="_blank" rel="noopener noreferrer">http://mirror1.babylon.network/gcc/releases/gcc-4.4.0/gcc-4.4.0.tar.bz2传送门<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li> <li>新设计团队，<a href="https://book.douban.com/subject/26762311/" target="_blank" rel="noopener noreferrer">编译系统透视<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li> <li>王亚刚，<a href="https://book.douban.com/subject/26984172/" target="_blank" rel="noopener noreferrer">深入分析GCC<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div> <div class="page-edit"><!----> <!----></div> <!----> </div> <!----></div></div>
    <script src="/assets/js/app.c70e21ad.js" defer></script><script src="/assets/js/115.e51d3c2f.js" defer></script>
  </body>
</html>
